package com.xindaoapp.framework;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;

import com.xindaoapp.framework.adapter.ViewPagerAdapter;
/**
 * ============================================================
 * 
 * 版权 : 新道APP (c) 2014
 * 
 * 作者 : 贺奕凯
 * 
 * 版本 : 1.0
 * 
 * 创建日期 : 2014-6-17 上午10:01:33
 * 
 * 描述 : 引导页面
 * 
 * 修订历史 ：
 * 
 * ============================================================
 **/

public class GuaidAct extends Activity {

	private ViewPager view_pager;
	private Button button;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.guaid);
		view_pager = (ViewPager) findViewById(R.id.view_pager);
		button = (Button) findViewById(R.id.button);
		button.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(GuaidAct.this, MainActivity.class));
			    finish();
			}
		});
		List<View> lists = new ArrayList<View>();
		ImageView imageView1 = new ImageView(this);
		imageView1.setBackgroundResource(R.drawable.guide_1);
		
		ImageView imageView2 = new ImageView(this);
		imageView2.setBackgroundResource(R.drawable.guide_2);
		
		ImageView imageView3 = new ImageView(this);
		imageView3.setBackgroundResource(R.drawable.guide_3);
		
		lists.add(imageView1);
		lists.add(imageView2);
		lists.add(imageView3);
		
		ViewPagerAdapter adapter = new ViewPagerAdapter(lists);
		view_pager.setAdapter(adapter);
		view_pager.setOnPageChangeListener(new OnPageChangeListener() {
			
			@Override
			public void onPageSelected(int arg0) {
				// TODO Auto-generated method stub
				if(arg0 == 2){
					button.setVisibility(View.VISIBLE);
				}
			}
			
			@Override
			public void onPageScrolled(int arg0, float arg1, int arg2) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void onPageScrollStateChanged(int arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
}
